﻿using UnityEngine;
using System.Collections;

public class cameraScript : MonoBehaviour {
	public Transform target;
	public float relativeHeigth = 10.0f;
    public float zDistance = 5.0f;
    public float dampSpeed = 2;

	void Awake () {
	
	}
	

    void Update () {
//        Vector3 newPos = target.position + (Quaternion.Euler(0.0f,target.rotation.y,0.0f)*new Vector3(0.0f, relativeHeigth, 5.0f));
 //       transform.position = Vector3.Lerp(transform.position, newPos, Time.deltaTime*dampSpeed);
		Vector3 tV=target.rigidbody.velocity.normalized*-1.0f;
		transform.position=Vector3.Lerp(transform.position,target.position+new Vector3(tV.x,1.0f,tV.z).normalized*10.0f,Time.deltaTime*dampSpeed);
		transform.LookAt(target);
	}

}
